package main.com.dhj.test02

object test01 {

    def main(args: Array[String]): Unit = {
        val tempValue1 = Seq[Double](1, 2, 3, 4, 5);
        val tempValue2 = WeeklyWeatherForecast(tempValue1).getTempC;
        println(tempValue2);
        println("-----------------------------------------------");

        WeatherForecast().temperatures = Seq[Double](1, 2, 3, 4, 5);
        println(WeatherForecast().getTempC);

        val obj0 = WeatherForecast();
        obj0.temperatures = Seq[Double](1, 2, 3, 4, 5);
        println(obj0.getTempC);

        println("-----------------------------------------------");

        WeatherForecast02().temperatures = Seq[Double](1, 2, 3, 4, 5);
        println(WeatherForecast02().getTempC);
        val obj01 = new WeatherForecast02();
        obj01.temperatures = Seq[Double](1, 2, 3, 4, 5);
        println(obj01.getTempC);

        println("-----------------------------------------------");
        WeatherForecast03.temperatures = Seq[Double](1, 2, 3, 4, 5);
        println(WeatherForecast03.getTempC);

        val obj03 = WeatherForecast03;
        obj03.temperatures = Seq[Double](1, 2, 3, 4, 5);
        println(obj03.getTempC)


    }


    case class WeeklyWeatherForecast(temperatures: Seq[Double]) {
        private def convertCtoF(temp: Double) = temp * 1.8 + 32;

        def getTempC: Seq[Double] = temperatures.map(convertCtoF);
    }

    case class WeatherForecast() {
        var temperatures: Seq[Double] = Seq[Double]();

        private def convertCtoF(temp: Double) = temp * 1.8 + 32;

        def getTempC: Seq[Double] = temperatures.map(ele => {
            // println("ele = " + ele);
            convertCtoF(ele);
        });
    }


    class WeatherForecast02() {
        var temperatures: Seq[Double] = Seq[Double]();

        private def convertCtoF(temp: Double) = temp * 1.8 + 32;

        def getTempC: Seq[Double] = temperatures.map(convertCtoF);
    }


    object WeatherForecast03 {
         var temperatures: Seq[Double] = Seq[Double]();

        private def convertCtoF(temp: Double) = temp * 1.8 + 32;

        def getTempC: Seq[Double] = temperatures.map(convertCtoF);
    }

}

